<template>
  <el-dialog
    title="表单预览"
    :visible="previewVisible"
    :show-close="false"
    fullscreen
    destroy-on-close
  >
    <div id="formContainer"></div>
    <div slot="footer" style="border-top: 1px solid #eee; padding: 8px">
      <el-button type="primary" @click="handleClose">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "Preview",
  props: {
    previewVisible: {
      type: Boolean,
      required: true,
    },
  },
  data() {
    return {};
  },
  methods: {
    handleClose() {
      this.$emit("update:previewVisible", false);
    },
  },
  watch: {
    previewVisible(val) {
      if (val) {
        this.$nextTick(() => {
          const dragController = this.$store.state.dragController;
          dragController._mountForm("formContainer", false);
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
#formContainer {
  width: 1020px;
  margin: 0 auto;
  background: #f7f7f7;
}
</style>